feat(qwen4): support Qwen3.8 Flash Next NVFP4, vision, and Windows serving - #232
feat(qwen4): support Qwen3.8 Flash Next NVFP4, vision, and Windows serving#232MaxKerkula wants to merge 3 commits into
Conversation
Integrate Qwen4-Exp architecture, FP8 expert offload, mmap-backed PLE, safe runtime constraints, tests, and a reproducible CUDA 13 serving image for single-GPU deployments. Co-authored-by: Cursor <cursoragent@cursor.com>
|
I tested this PR at Environment: Linux 7.2 (x86_64), RTX 5090 / CC 12.0, Python 3.13.15, PyTorch 2.11.0+cu130, Triton 3.6.0, Transformers 5.16.1. 1. Linux first-request crash for Qwen top-k=10The checkpoint converts and the server becomes healthy, but the first prefill crashes in Qwen3.8-Flash-Next has 512 routed experts and activates 10 experts per token. A minimal fix is to use that same numerically equivalent fallback for non-power-of-two triton_topk_supported = topk > 0 and (topk & (topk - 1)) == 0
triton_topk_installed = is_triton_kernels_installed()
if not triton_topk_installed or not triton_topk_supported:
return _torch_fused_topk(
gating_output, topk, renormalize, num_token_non_padded
)I added a CUDA regression with logits shaped 2. Native vision dependencies are absent from project metadataThe Qwen vision path requires Pillow and TorchVision, but neither is declared by this PR. A clean install therefore cannot process images until they are installed separately. For the PR's Torch 2.11/CUDA 13 setup I used: "Pillow>=11,<13"
"torchvision>=0.26,<0.27"
[tool.uv.sources]
torchvision = { index = "pytorch-cu130" }This resolved to Pillow 12.3.0 and TorchVision 0.26.0+cu130. After these changes, the focused suite passed 211 tests and live Linux serving passed text, strict tool calls, tool-result continuation, native 2920×1944 vision, coding execution, and a 16,023-token cross-prefill-boundary needle test. Decode measured 35.1 tok/s on the RTX 5090 profile. I have a clean five-file patch with the fallback, dependency declarations, and regressions and can open a follow-up PR if that is preferable. |
|
Thanks for the detailed Linux test and the exact reproduction. Both findings are valid and are fixed on the PR head in
I reran the focused fused-top-k tests on the current head: 3 passed, including Your Linux RTX 5090 serving evidence is very useful. If you can retest the current head, that would confirm the fix in the environment that exposed the blocker. No separate follow-up PR is needed for these two items. |
RTX 4090 / Qwen3.8-Flash-Next-NVFP4 validation (256k allocation)Tested the current PR head Runtime verdict: the NVFP4 FTW/offload path works on an RTX 4090, including vision, reasoning parsing, structured tool calls with the correct parser, and a real near-limit 249,999-token prompt under a 262,144-token allocation. I did find three integration issues below. Environment and launch configuration
FTW conversion and load
Direct-engine smoke returned the exact requested text:
Longer server generations stabilized around 15.2–15.6 tok/s. One performance caveat is logged: Functional and context results
The near-limit test used tokenizer-exact construction and the server's returned usage count, not a character-count estimate. BenchLocal quality checks (v0.9.8)
No quality response ended due to Test/build findings
Tool-parser issueLaunching with Restarting with Overall, the core 4090 NVFP4 + vision + 256k runtime path is solid in this test. The scheduler test updates, Docker lockfile mismatch, and Qwen4Exp parser auto-selection are the concrete follow-ups I found. |
Follow-up: profiled hybrid A/BI profiled and tested the same checkpoint with
Hybrid loaded correctly with a 15-thread AVX2 CPU MoE pool and the profiled split. A same-prompt, same-allocation direct-engine A/B over 291 output tokens produced:
So profiled hybrid was 14.4% slower than plain offload on this Threadripper Pro 5955WX + RTX 4090, despite the bandwidth microbenchmark recommending it. The likely missing cost in the selection rule is the per-layer CPU submit/synchronize and merge overhead across 48 MoE layers; kernel bandwidth alone overpredicts the benefit. This is with the full 262,144-token KV allocation and a 1,024-slot expert cache. This corrects the performance interpretation: offload is the faster measured backend on this host/configuration, while hybrid functionality itself loads and produces correct output. |
|
I opened a draft review stack directly on the current #232 head: MaxKerkula#1 It adds the synthetic hardware-fit/runtime work for Qwen3.8-Flash-Next on a 12 GB Windows GPU: active NVFP4, sparse-QSA differentials, Q3 PLE, file-tiered experts, modular artifact orchestration, and the Windows JIT portability pieces. It also records #226 as a parallel upstream dependency. This is intentionally not merge-ready: no model payload has been downloaded or converted, and real-artifact quality/runtime plus cold/async SSD behavior remain unresolved. Feedback on component boundaries and which pieces should be split upstream would be very welcome. |
Summary
Validation
Platform notes